/*
 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// NOLINTBEGIN(readability-identifier-naming)

% Builtins.spaces.each do |space|
%   if (space.methods.length + space.setters.length + space.getters.length) > 0
void SetFunctionsGen<%= space.name  %>(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &<%= space.name.snakecase %>_func) const
{
%       space.methods.each do |method|
<%= method.gen_setfunction(space.name.snakecase, space.name.snakecase + "_func") %>
%       end

%       space.getters.each do |getter|
<%= getter.gen_setfunction(space.name.snakecase, space.name.snakecase + "_func") %>
%       end
}

%   end
%   if space.prototype && (space.prototype.methods.length + space.prototype.setters.length + space.prototype.getters.length) > 0
void SetFunctionsGen<%= space.name  %>Proto(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &<%= space.name.snakecase %>_proto) const
{
%       space.prototype.methods.each do |method|
<%= method.gen_setfunction(space.name.snakecase + "::proto", space.name.snakecase + "_proto") %>
%       end
%       space.prototype.getters.each do |getter|
<%= getter.gen_setfunction(space.name.snakecase + "::proto", space.name.snakecase + "_proto") %>
%       end
%       space.prototype.setters.each do |setter|
%           raise "Setters without corresponding getters are not implemented" if !space.prototype.getters.find do |i|
%               i.id == setter.id
%           end
%       end
}

%   end
% end

// NOLINTEND(readability-identifier-naming)
